<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Perform POST request with data to be encoded</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-post-data.html">http_post_data</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-put-data.html">http_put_data</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-post-fields" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_post_fields</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.10.0)</p><p class="refpurpose"><span class="refname">http_post_fields</span> &mdash; <span class="dc-title">Perform POST request with data to be encoded</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-post-fields-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>http_post_fields</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$url</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$data</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$files</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$info</code></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   Performs an HTTP POST request on the supplied url.
  </p>
  <p class="para">请查阅完整的 <a href="http.request.options.html" class="link">request 选项组</a> 列表。</p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-post-fields-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">url</code></em></dt>

     <dd>

      <p class="para">
       URL
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">data</code></em></dt>

     <dd>

      <p class="para">
       Associative array of POST values
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">files</code></em></dt>

     <dd>

      <p class="para">
       Array of files to post
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       <a href="http.request.options.html" class="link">request 选项组</a>
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">info</code></em></dt>

     <dd>

      <p class="para">
       <a href="function.http-get.html#http.request.info" class="link">请求/响应信息</a>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.http-post-fields-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时用字符串返回 HTTP 响应，失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-post-fields-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4279">
    <p><strong>Example #1 A <span class="function"><strong>http_post_fields()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fields&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'mike'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'pass'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'se_ret'<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$files&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'name'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'uimg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'type'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'file'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'./profile.jpg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;)<br />);<br /><br /></span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">http_post_fields</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$fields</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$files</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>



 


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-post-data.html">http_post_data</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-put-data.html">http_put_data</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
